<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/static/crm/lib/layui-v2.6.3/css/layui.css">
    <style>
        .layui-container{
            margin-top: 120px;
            
        }
    </style>
</head>
<body>
<div class="layui-container">     
    <form class="layui-form" action="">
        <div class="layui-form-item">
          <label class="layui-form-label">输入框</label>
          <div class="layui-input-inline">
            <input type="text" name="xls" id="xls" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
          </div>
          <button type="button" class="layui-btn" id="test1">
            <i class="layui-icon">&#xe67c;</i>上传Excel
          </button>
        </div>
       
        <div class="layui-form-item">
          <label class="layui-form-label">选择框</label>
          <div class="layui-input-block">
            <select name="city" lay-verify="required">
              <option value=""></option>
              <option value="0">北京</option>
              <option value="1">上海</option>
              <option value="2">广州</option>
              <option value="3">深圳</option>
              <option value="4">杭州</option>
            </select>
          </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">导入模板</label>
            <a href="/xlsTemp/template.xlsx">模板下载</a>
        </div>
        
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
      </form>
    </div>
      <script src="/static/crm/lib/layui-v2.6.3/layui.js"></script>
      <script>
        layui.use(['jquery','upload'], function(){
          var upload = layui.upload;
          var $ = layui.jquery;
           
          //执行实例
          var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,accept:'file'
            ,exts:'xlsx'
            ,url: '{:url("upload")}' //上传接口
            ,done: function(res){
                console.log(res);
              if( res.code == 0 ){
                  $('#xls').val(res.data.src);
              }
            }
            ,error: function(){
              //请求异常回调
            }
          });
        });
        </script>
</body>
</html>